home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.002.BusyBox / busybox.p / uwindow.p < prev   
Encoding:
Text File  |  1990-06-19  |  4.3 KB  |  172 lines  |  [TEXT/MPS ]

  1. {**********************************************************************
  2. {*
  3. {* BusyBox uWindow -- Version 3.0  (interface)
  4. {*
  5. {* Copyright (c)
  6. {* Apple Computer, Inc.  1986-1989
  7. {* All Rights Reserved.
  8. {*
  9. {* This file contains the interface to the code which implements  
  10. {* windows in the busybox program.
  11. {*
  12. {**********************************************************************}
  13.  
  14. UNIT uWindow;
  15.  
  16. INTERFACE
  17.  
  18. USES
  19.  
  20.        types,
  21.        GSOS,
  22.        locator,
  23.        quickdraw,
  24.        fonts,
  25.        MEMORY,
  26.        intMath,
  27.        events,
  28.        controls,
  29.        windows,
  30.        lineedit,
  31.        dialogs,
  32.        menus,
  33.        DESK,
  34.        STDFILE,
  35.        resources,
  36.        TextEdit,
  37.        
  38.        
  39.        uGlobals,
  40.        uUtils;
  41.  
  42. var
  43.     TheMainWindow,
  44.     ButtonsWindow,
  45.     StatTextWindow,
  46.     LineEditWindow,
  47.     PicturesWindow,
  48.     PopUpsWindow,
  49.     TextEditWindow,
  50.     ListsWindow         : GrafPortPtr;
  51.  
  52. procedure SetUpWindows;            {Initialize variables for stacking windows}
  53. procedure DrawThisWindow;
  54. procedure DoCloseTop;
  55. procedure OpenThisWindow   (CtlID : integer);
  56.  
  57.  
  58.  
  59.  
  60. IMPLEMENTATION
  61.  
  62. {$R-}
  63.  
  64. const    MainWindowID = $2000;
  65.  
  66.  
  67. {**********************************************************************}
  68. {
  69. { DrawThisWindow
  70. {
  71. { This routine draws the contents of all the windows.
  72. {
  73. {*
  74. {* Warning:  Do not make any calls that use the libraies or use
  75. {* short addressing without setting the dbr to ~globals.
  76. {*
  77. {**********************************************************************}
  78. procedure DrawThisWindow;
  79.     begin
  80.         DrawControls(GetPort);
  81.     END;
  82.     
  83. {**********************************************************************}
  84. {
  85. { DoCloseTop
  86. {
  87. { This routine closes the topmost window.  We do a little work to
  88. { prevent the main window from being closed.
  89. {
  90. {**********************************************************************}
  91. procedure DoCloseTop;
  92.     var
  93.         k : integer;
  94.         TempWin : GrafPortPtr;
  95.         
  96.     begin
  97.         { Get the front window into a local variable }
  98.         TempWin := FrontWindow;
  99.         
  100.         { start the count at 1 since we never close the main window }
  101.         k := 1;
  102.         
  103.         { Find the window entry, close the window, and zero the entry }
  104.         repeat
  105.         
  106.             if TempWin = WindowList[k] then
  107.                 begin
  108.                     CloseWindow(TempWin);
  109.                     WindowList[k] := NIL;
  110.                     k := NumWindows;
  111.                 end
  112.             else
  113.                 k := k+1;
  114.         until k >= NumWindows;      
  115.     end;
  116.     
  117. {****************************************************************************}
  118. {
  119. { OpenThisWindow
  120. {
  121. { This routine either opens the specified window or brings it to the top
  122. { if it is already open.
  123. {
  124. { If it is not open, we open it with NewWindow2 invisibly, adjust the window's
  125. { location and then show and select the window.
  126. {
  127. { ID values for controls in the main window are assumed here to be from 1..n
  128. {
  129. {****************************************************************************}
  130. procedure OpenThisWindow   (CtlID : integer);
  131.     begin
  132.         if WindowList[CtlID] = NIL then
  133.             begin
  134.                 WindowList[CtlID] := NewWindow2(NIL,0,@DrawThisWindow,NIL,2,
  135.                          Ref(POINTER(MainWindowID+CtlID)),rWindParam1);
  136.                 if CtlID < Prog1ID then 
  137.                     begin
  138.                         MoveWindow (50+8*StaggerCount,50+8*StaggerCount,WindowList[CtlID]);
  139.                         StaggerCount := StaggerCount+1;
  140.                     end;
  141.                 ShowWindow(WindowList[CtlID]);
  142.                 SelectWindow(WindowList[CtlID]);                
  143.             end
  144.         else SelectWindow(WindowList[CtlID]);
  145.     end;
  146.     
  147.     
  148. {*****************************************************************************}
  149. {
  150. { SetUpWindows
  151. {
  152. { Sets up WindowList record for use through out the program.
  153. {
  154. {*****************************************************************************}
  155. procedure SetUpWindows;
  156.     var
  157.         k : integer;
  158.         
  159.     begin   {of SetUpWindows}
  160.         { Zero out the entries in the window list. }
  161.         for k := 0 to NumWindows-1 do WindowList[k] := NIL;
  162.         
  163.         { Open the main window }
  164.         WindowList[0] := NewWindow2(NIL,0,@DrawThisWindow,NIL,2,ref(MainWindowID),
  165.                                rWindParam1);
  166.     end;    {of SetUpWindows}
  167.     
  168.  
  169.  
  170.  
  171. END.
  172.